package com.example.javamaday.leetcode;

import com.example.javamaday.leetcode.base.TreeNode;

public class LeetCodeTest0404 {

    private int result = 0;

    public static void main(String[] args) {

    }

    public int sumOfLeftLeaves(TreeNode root) {
        scanTree(root);
        return result;
    }

    private void scanTree(TreeNode root) {
        if (root.left == null && root.right == null) {
            return;
        }
        if (root.left != null) {
            if (root.left.left == null && root.left.right == null) {
                result += root.left.val;
            } else {
                scanTree(root.left);
            }
        }
        if (root.right != null) {
            scanTree(root.right);
        }
    }

}
